#include <stdio.h>

void toFan(int x[]){
	if(x[0]==1){
		for(int i=1; i<8; i++){
			x[i] = 1-x[i]; 
		}			
	} 	
}

void readBin(int n, int a[]){
	int m = n;
	for(int i=7; i>=0; i--){
		a[i] = m%10;	     
		m = int(m/10);		
	}		
} 

int getNumber(int x[]){
	int sum = 0;	
	int u = 1;
	for(int i=7; i>0; i--){
		sum += x[i]*u;	    		
		u *= 2;
	}		
	if(x[0]==1){
		return 0-sum;
	}
	else{
		return sum;
	}
} 

int main(){
	int n; 
	scanf("%d", &n); 
	int x[8];
	readBin(n, x);  
	toFan(x); 
	printf("%d", getNumber(x));	
}
